<template>
	<view class="page">
		<myNavBar title="XXX案件" barIcon="back" rightText="协办管理" @clickRight='clickRight'></myNavBar>
		<uni-segmented-control :current="current" :values="items" @clickItem="onClickItem" styleType="text"
			activeColor="#1989FA">
		</uni-segmented-control>
		<view class="content">
			<view v-show="current == 0 && editId">
				<view class="chat-tools-item">
					<file-upload :onSuccess="onUploadFileSuccess" :onError="onUploadFileFail">
						<!-- <view class="tool-icon iconfont icon-folder"></view> -->
						<button class="button" type="primary" size="mini">文件上传</button>
					</file-upload>
					<!-- <view class="tool-name">文件</view> -->
				</view>
				<casesource :editId="editId" :isUpdateFileList="isUpdateFileList"></casesource>
			</view>
			<view v-show='current == 1 && editId'>
				<casefenxi :editId="editId"></casefenxi>
			</view>
		</view>
	</view>
</template>

<script>
	import casesource from "./case-source.vue"
	import casefenxi from "./case-fenxi.vue"
	export default {
		components: {
			casesource,
			casefenxi
		},
		data() {
			return {
				items: ['原始资料', '案件分析'],
				current: 0,
				editId: '',
				isUpdateFileList: false,
			}
		},
		onLoad(options) {
  		  // options 是一个对象，包含了传递过来的参数
  		  this.editId = options.id;
  		  console.log('Received ID:', this.editId);
  		},
		methods: {
			onUploadFileSuccess(file, res) {
				console.log('file==============>', file);
				console.log('res==============>', res);
				if(res.code == 200) {
					this.isUpdateFileList = true;
				}
			},
			onUploadFileFail(file, res) {
				let msgInfo = JSON.parse(JSON.stringify(file.msgInfo));
				msgInfo.loadStatus = 'fail';
				// this.$store.commit("insertMessage", msgInfo);
			},
			clickRight() {
				uni.navigateTo({
					url: 'case-xieban',
				});
			},
			onClickItem(e) {
				if (this.current != e.currentIndex) {
					this.current = e.currentIndex;
				}
			},
		}
	}
</script>

<style lang="less" scoped>
	::v-deep .segmented-control__text {
		font-size: 25rpx;
	}

	.content {
		height: calc(100vh - 110px);
		width: 100vw;
		overflow-y: scroll;
		.chat-tools-item {
			padding: 16rpx;
		}
	}
</style>